import request from '@/utils/request'

export default {
  getRoleList(searchModel) {
    return request({
      url: '/myboard/role/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        username: searchModel.username
      }
    })
  },
  addRole(role) {
    return request({
      url: '/myboard/role/add',
      method: 'post',
      data: role
    })
  },
  updateRole(role) {
    return request({
      url: '/myboard/role/update',
      method: 'put',
      data: role
    })
  },
  saveRole(role) {
    if (role.roleId == null || role.roleId === undefined) {
      return this.addRole(role)
    }
    return this.updateRole(role)
  },
  getRoleById(id) {
    return request({
      // url: '/role/byId',
      url: `/myboard/role/${id}`,
      method: 'get'
      // params: {
      //   id: id
      // }
    })
  },
  delRoleById(id) {
    return request({
      url: `/myboard/role/${id}`,
      method: 'delete'
    })
  },
  getRoleListAll() {
    return request({
      url: `/myboard/role/all`,
      method: 'get'
    })
  }
}
